#pragma once

#include <compl.h>


#define cyclestamp_get()		rdcnt()
#define cyclestamp_diff(stamp)		(rdcnt() - stamp)

typedef word_t cyclecnt_t;
DECL_SINTF(cyclecnt_t, cyclecnt_get, ())
DECL_SINTF(cyclecnt_t, cyclecnt_diff, (cyclecnt_t cnt))
DECL_MINTF(cycles, cyclecnt_get, cyclecnt_diff)
/* 依赖 */
#define DEF_CYCLE(name, rdcnt)  \
static inline cyclecnt_t name##_get(){ return cyclestamp_get(rdcnt); }\
static inline cyclecnt_t name##_delta(cyclecnt_t cnt){ return cyclestamp_diff(rdcnt);}\
NEW_MINTF(cycles, name, name##_get, name##_delta)


// #include <unistd.h>
// #define MEASURE_GAP (10000)
// static inline double cyclestamp_measure()
// {
//     double cycles_per_nanoseconds;

//     word_t start = rdcnt();
//     usleep(MEASURE_GAP);
//     word_t end = rdcnt();
//     cycles_per_nanoseconds = (double)(end - start) / (MEASURE_GAP * 1000);
//     printf("cycles_per_nanoseconds: %lf\n", cycles_per_nanoseconds);
//     return cycles_per_nanoseconds;
// }
